package com.zt.ztyh.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zt.ztyh.admin.service.UserService;
import com.zt.ztyh.model.common.Result;
import com.zt.ztyh.model.common.ResultCodeEnum;
import com.zt.ztyh.model.dto.UserDto;
import com.zt.ztyh.model.entity.User;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/user")
public class UserAdminController {

    @Autowired
    private UserService userService;
    @GetMapping("/{page}/{limit}")
    @Operation(summary = "用户列表")
    public Result<Page<User>> getUserList(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit,
                                          UserDto userDto){
        return Result.build(this.userService.findAll(page,limit,userDto), ResultCodeEnum.SUCCESS);
    }



    @DeleteMapping("/{id}")
    public Result deleteUser(@PathVariable("id") Long id){
        this.userService.removeById(id);
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }
}
